#
# Be sure to run `pod lib lint mosdks.podspec' to ensure this is a
# valid spec before submitting.
#
# Any lines starting with a # are optional, but their use is encouraged
# To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html
#

Pod::Spec.new do |s|
  s.name             = 'mosdks'
  s.version          = '0.1.0'
  s.summary          = 'A short description of mosdks.'
# This description is used to generate tags and improve search results.
#   * Think: What does it do? Why did you write it? What is the focus?
#   * Try to keep it short, snappy and to the point.
#   * Write the description between the DESC delimiters below.
#   * Finally, don't worry about the indent, CocoaPods strips it!

  s.description      = <<-DESC
  use_frameworks! :linkage => :static
  


TODO: Add long description of the pod here.
                       DESC

  s.homepage         = 'https://github.com/zhuxietong@me.com/mosdks'
  # s.screenshots     = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
  s.license          = { :type => 'MIT', :file => 'LICENSE' }
  s.author           = { 'zhuxietong@me.com' => 'zhuxietong@me.com' }
  s.source           = { :git => 'https://github.com/zhuxietong@me.com/mosdks.git', :tag => s.version.to_s }
  # s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'
  

  s.ios.deployment_target = '10.0'
  s.pod_target_xcconfig = { 'SWIFT_VERSION' => '5.1' }
  s.swift_versions = '5.1'
  
  s.static_framework = true
  s.user_target_xcconfig = {'OTHER_LDFLAGS' => '-ObjC'}
  subs = Array.new

  s.dependency 'soapp'
  s.subspec 'Base' do |sub|
    subs << 'Base'
    sub.name = 'Base'
    sub.source_files = [
    'mosdks/Classes/Base/*.{swift,h,m}',
    'mosdks/Classes/Base/**/*.{swift,h,m}',
    'mosdks/Classes/Base/**/**/*.{swift,h,m}',
    ]
   end
  
  s.subspec 'Alipay' do |sub|
      subs << 'Alipay'
      sub.name = 'Alipay'
      sub.dependency 'mosdks/Base'

      sub.source_files = [
      'mosdks/Classes/Alipay/*.{swift,h,m,modulemap}',
      'mosdks/Classes/Alipay/**/*.{swift,h,m,modulemap}',
      'mosdks/Classes/Alipay/**/**/*.{swift,h,m,modulemap}',
#      'mosdks/Vendors/AlipaySDK/AlipaySDK.framework/*.{swift,h,m,modulemap}',
#      'mosdks/Vendors/AlipaySDK/AlipaySDK.framework/**/*.{swift,h,m,modulemap}',

      ]
#      sub.dependency 'AlipaySDK-iOS'
      vendor = 'mosdks/Vendors/AlipaySDK/AlipaySDK.framework'
      vendorBundle = 'mosdks/Vendors/AlipaySDK/AlipaySDK.bundle'
      sub.resources  = [vendorBundle]
      sub.vendored_frameworks = vendor
      sub.ios.frameworks = "UIKit","Foundation","CFNetwork","SystemConfiguration","QuartzCore","CoreGraphics","CoreMotion","CoreTelephony","CoreText","WebKit"
      sub.ios.libraries = 'c++','z'
      sub.preserve_paths = vendor
      sub.pod_target_xcconfig = {
        'FRAMEWORK_SEARCH_PATHS' => '$(inherited) $(SRCROOT)/**',
        'OTHER_LDFLAGS' => '$(inherited) -undefined dynamic_lookup'
      }
#      # 创建 Module
#      begin
#      s.prepare_command = <<-EOF
#      rm -rf '#{vendor}/Modules'
#      mkdir '#{vendor}/Modules'
#      touch '#{vendor}/Modules/module.modulemap'
#      cat <<-EOF > '#{vendor}/Modules/module.modulemap'
#      framework module AlipaySDK {
#          umbrella header "AlipaySDK.h"
#          export *
#      }
#      \EOF
#      EOF
#      rescue => e
#      puts __FILE__
#      end
      
      begin
      path = 'mosdks/Classes/Core'
      s.prepare_command = <<-EOF
      rm -rf '#{vendor}/Modules'
      mkdir '#{vendor}/Modules'
      touch '#{vendor}/Modules/module.modulemap'
      cat <<-EOF > '#{vendor}/Modules/module.modulemap'
       framework module AlipaySDK {
               umbrella header "AlipaySDK.h"
               export *
           }
      \EOF
      EOF
      rescue => e
      puts "faild to write AlipaySDK Modules"
      end
  #
      
  end
  
  s.subspec 'WeChat' do |sub|
      subs << 'WeChat'
      sub.name = 'WeChat'
      sub.dependency 'mosdks/Base'
      sub.source_files = [
      'mosdks/Classes/WeChat/*.{swift,h,m,modulemap}',
      'mosdks/Classes/WeChat/**/*.{swift,h,m,modulemap}',
      'mosdks/Vendors/WeChat/*.{swift,h,m,modulemap}',
      'mosdks/Vendors/WeChat/**/*.{swift,h,m,modulemap}',
      'mosdks/Vendors/WeChat/**/**/*.{swift,h,m,modulemap}',
      ]
      s.xcconfig = {
           'CLANG_CXX_LANGUAGE_STANDARD' => 'c++11',
           'CLANG_CXX_LIBRARY' => 'libc++'
      }

      sub.public_header_files = 'mosdks/Vendors/WeChat/*,h'
      sub.vendored_libraries  = 'mosdks/Vendors/WeChat/libWeChatSDK.a'
      sub.libraries = 'c++', 'sqlite3', 'z'
      sub.frameworks = 'CoreTelephony', 'SystemConfiguration', 'Security', 'CoreTelephony', 'CFNetwork'
      sub.pod_target_xcconfig = { 'OTHER_LDFLAGS' => '-all_load' }
      
  end
  

  s.subspec 'JPush' do |sub|
      subs << 'JPush'
      sub.name = 'JPush'
      sub.dependency 'mosdks/Base'
      sub.dependency 'JCore'
      sub.dependency 'JPush'

      sub.source_files = [
      'mosdks/Classes/JPush/*.{swift,h,m,modulemap}',
      'mosdks/Classes/JPush/**/*.{swift,h,m,modulemap}',
      'mosdks/Vendors/JPush/*.{swift,h,m,modulemap}',
      'mosdks/Vendors/JPush/**/*.{swift,h,m,modulemap}',
      'mosdks/Vendors/JPush/**/**/*.{swift,h,m,modulemap}',
      ]

      
      sub.public_header_files = 'mosdks/Vendors/JPush/*.h'
#      sub.vendored_libraries  = 'mosdks/Vendors/JPush/jpush-ios-3.3.2.a'
      sub.libraries =  "z","resolv"
      sub.frameworks = "UIKit","CFNetwork","CoreFoundation","CoreTelephony","SystemConfiguration","CoreGraphics","Foundation","Security","WebKit"
      sub.weak_frameworks = "UserNotifications"
      sub.pod_target_xcconfig = { 'OTHER_LDFLAGS' => '-all_load' }

#      sub.pod_target_xcconfig = { 'OTHER_LDFLAGS' => '-all_load' }
#      sub.pod_target_xcconfig = {
#             'LIBRARY_SEARCH_PATHS' => '$(inherited) $(SRCROOT)/**',
#             'OTHER_LDFLAGS' => '$(inherited) -undefined dynamic_lookup',
#             'HEADER_SEARCH_PATHS' => '$(inherited)'
#      }
     
      sub.pod_target_xcconfig = {'LIBRARY_SEARCH_PATHS' => '$(inherited) $(PODS_ROOT)',
      'OTHER_LDFLAGS' => '$(inherited) -undefined dynamic_lookup'
      }

      sub.user_target_xcconfig =   {'OTHER_LDFLAGS' => ['-lObjC']}
  end
  

  
  s.subspec 'Core' do |sub|
    subs << 'Core'
    sub.name = 'Core'
    sub.source_files = [
    'mosdks/Classes/Core/*.{swift,h,m}',
    'mosdks/Classes/Core/**/*.{swift,h,m}',
    'mosdks/Classes/Core/**/**/*.{swift,h,m}',
    ]
   end
  
  s.subspec 'Share' do |sub|
      subs << 'Share'
      sub.name = 'Share'
      sub.dependency 'mosdks/Base'
      sub.source_files = [
      'mosdks/Classes/Share/*.{swift,h,m,modulemap}',
      'mosdks/Classes/Share/**/*.{swift,h,m,modulemap}',
      ]
      sub.resource_bundles  = {
          'mosdksShare' => ['mosdks/Classes/Share/*.xcassets']
      }
      
      
  end
  
    s.dependency 'soapp'

    s.subspec 'momall' do |sub|
       sub.name = 'momall'
       sub.dependency 'TZImagePickerController'
       sub.dependency 'DateTimePicker'
       
       sub.source_files = [
       'mosdks/Classes/momall/*.{swift,h,m}',
       'mosdks/Classes/momall/**/*.{swift,h,m}',
       'mosdks/Classes/v/**/**/*.{swift,h,m}',
       'mosdks/Classes/momall/**/**/**/*.{swift,h,m}',
       'mosdks/Classes/momall/**/**/**/**/*.{swift,h,m}',
       'mosdks/Classes/momall/**/**/**/**/**/*.{swift,h,m}',
       ]
       sub.resources  = ["mosdks/Classes/momall/template.bundle"]

  #     s.resource_bundles = {
  #       'momall' => ['momall/Assets/*.png']
  #    }
   end

   s.default_subspec = 'Base'

    
  
  
#  s.subspec 'TXIM' do |sub|
#    subs << 'TXIM'
#    sub.name = 'TXIM'
#    sub.dependency 'TXIMSDK_iOS'
#    sub.dependency 'mosdks/Base'
#
#    sub.source_files = [
#    'mosdks/Classes/TXIM/*.{swift,h,m}',
#    'Example/Pods/TXIMSDK_iOS/**/*.{swift,h,m,modulemap}',
#    'Example/Pods/TXIMSDK_iOS/**/**/*.{swift,h,m,modulemap}',
#    ]
#
#  end
    
    
    
  puts subs
  
#    begin
#    path = 'mosdks/Classes/Core'
#    s.prepare_command = <<-EOF
#    rm -rf '#{path}/core'
#    mkdir '#{path}/core'
#    touch '#{path}/core/core.swift'
#    info='#{subs}'
#    cat <<-EOF > '#{path}/core/core.swift'
#    public class MoCore {
#        static func initSDK(){
#            let sdks = $info
#            print(sdks)
#        }
#    }
#    \EOF
#    EOF
#    rescue => e
#    puts "erro------os"
#    end    
##
  
  s.default_subspec = 'Share','WeChat','JPush','Core'

  
  # s.resource_bundles = {
  #   'mosdks' => ['mosdks/Assets/*.png']
  # }

  # s.public_header_files = 'Pod/Classes/**/*.h'
  # s.frameworks = 'UIKit', 'MapKit'
  # s.dependency 'AFNetworking', '~> 2.3'
end
